import NProgress from 'nprogress';
import { createRouter, createWebHashHistory } from 'vue-router';
// apis
// hooks
// utils
// stores
// mixins
// configs
// components
import LayoutSystem from '@src/layouts/system/LayoutSystem.vue';

import Cesium from '@src/views/cesium/index.vue';

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    { path: '/', redirect: '/system' },
    {
      path: '/system',
      name: 'systemLayout',
      component: LayoutSystem,
      redirect: '/system/cesium',
      children: [{ path: 'cesium', component: Cesium }],
    },
  ],
});

const whiteRouterList = ['/login'];
router.beforeEach((to, from, next) => {
  NProgress.start();
  if (whiteRouterList.includes(to.path)) {
    next();
  } else {
    next();
  }
  NProgress.done();
});

export default router;
